<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //普通的函数
        //  let tw=function(a,b){
        //      return a+b;
        //  }
        //简化的箭头函数
        let tw=(a,b)=>{
          return a+b;
        };
        console.log(tw(1,2)); 

        //过滤
        let arr=[1,12,45,15,123,2].filter(item => item>10); //省略return function
        console.log(arr);
        //有时候箭头函数也不是万能的，比如递归函数，事件处理的时候
        //5的结城

         function func(number){
            //  if(number==1)return 1;
            //  else{
            //     return  func(number-1)*number;
            //  }
           return  number ==1?1:number*func(number-1);//简写

         }
         console.log(func(5));

         //递归输出小星星
         function star(num){
             if(num==0) return  document.write("星星画完了");
             document.write("*".repeat(num)+ "</br>");
             star(--num);
         }
         star(5)
 </script>
</body>
</html>